<template>
	<view class="content">
		<view class="menu-item">
			<view class="tab-item" :class="tabActive==0?'active':''" @click="bindActive(0)">全部</view>
			<view class="tab-item" :class="tabActive==1?'active':''" @click="bindActive(1)">党群综合部门</view>
			<view class="tab-item" :class="tabActive==2?'active':''" @click="bindActive(2)">县直部门</view>
			<view class="tab-item" :class="tabActive==3?'active':''" @click="bindActive(3)">乡镇</view>
		</view>
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id"
					@click="navigate('/pages/work/detail?id='+item.departmentId+'&title='+item.unitName)">
					<view class="name">{{index+1}}.{{item.unitName}}</view>
					<view class="iconfont icon-youjiantou"></view>
				</view>
			</template>
			<view v-else style="text-align: center;">暂无数据</view>
			<!-- <view v-if="list.length>0&&!listConf.more" style="text-align: center;">没有更多了</view> -->
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getWorkListApi
	} from '@/api/work.js'
	export default {
		data() {
			return {
				type: null,
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				},
				list: [{
						departmentId: 6,
						id: 6,
						sort: 0,
						type: 18,
						unitName: "县委办"
					},
					{
						departmentId: 7,
						id: 7,
						sort: 0,
						type: 18,
						unitName: "人大办",
					},
					{
						departmentId: 12,
						id: 12,
						sort: 0,
						type: 18,
						unitName: "政法委"
					},
					{
						departmentId: 13,
						id: 13,
						sort: 0,
						type: 18,
						unitName: "法院"
					},
					{
						departmentId: 14,
						id: 14,
						sort: 0,
						type: 18,
						unitName: "检察院"
					}
				],
				tabActive: 0
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			bindActive(index) {
				this.tabActive = index
				//	this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getWorkListApi({
					type: this.tabActive
				}).then(data => {
					uni.hideLoading()
					this.list = data.list1 || [];
					//this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		// onReachBottom() {
		// 	if (this.listConf.more) {
		// 		this.listConf.page++;
		// 		this.getList()
		// 	}
		// },
		onLoad() {
			//this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F5F5F5;
		width: 100%;
		min-height: 100vh;

		.menu-item {
			width: 100%;
			height: 200rpx;
			background-color: #157EFE;
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			color: #fff;

			.tab-item {
				margin-top: 30rpx;
				height: 60rpx;
				font-size: 30rpx;
			}

			.tab-item.active {
				font-size: 34rpx;
				font-weight: bold;
				height: 60rpx;
				border-bottom: 6rpx solid #fff;
			}
		}

		.info-block {
			min-height: 80vh;
			display: flex;
			flex-direction: column;
			background: #F5F5F5;
			margin-top: -90rpx;
			border-radius: 40rpx;
			height: auto;
			position: relative;
			padding: 30rpx;

			.info-item {
				height: 150rpx;
				box-shadow: 0 0 10px 0 #dedede;
				background: #fff;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;
				align-items: center;

				.name {
					font-weight: bold;
					font-size: 34rpx;
				}

				.iconfont {
					color: #CBCBCB;
				}
			}
		}
	}
</style>